<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			function getP(){
				//document.getElementsByTagName("p")[0];
				var  t=document.getElementById("timer");
				//alert(t.nextSibling.nodeType);
				while(t.nextSibling.nodeType!=1){
					t=t.nextSibling;
				}
				
				t.nextSibling.innerHTML="We change lives!";
			}
			function getP2(){
				//document.getElementsByTagName("p")[0];
				var  t=document.getElementById("timer");
				t=t.nextElementSibling||t.nextSibling;  
				t.innerHTML="We change lives!";
			}
			function getDiv(){
				var d=document.getElementById("v1");
				alert(d.nodeName+","+d.nodeType+",value="+d.nodeValue);
				alert(d.childNodes.length);//3
				alert(d.children.length);
			}
		</script>
	</head>
	<body>
		<h2 id="timer">Date的使用方法</h2>
		<p></p>
		<div id="v1">22222
			<ul>
				<li></li>
			</ul>
		</div>
		<input type="button" value="获得p" onclick="getP2()"/>
		<input type="button" value="获得div" onclick="getDiv()"/>
	</body>
</html>
